package missPuff.com;

import java.util.List;

import utils.com.DBtoVideoListUtils;

import model.com.SeasonInfo;
import model.com.VideoInfo;
import android.app.Activity;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

public class SeasonGridActivity extends Activity {
	private ImageView season_pic;
	private TextView season_title;
	private TextView season_count;
	private GridView video_grid;
	private Button bt_back;
	private List<VideoInfo> videoList;
	private SeasonInfo seasonInfo; 
	private DBtoVideoListUtils dbtoVideoListUtils;
	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		season_pic = (ImageView) findViewById(R.id.season_pic);
		season_title = (TextView) findViewById(R.id.season_title);
		season_count = (TextView) findViewById(R.id.season_count);
		video_grid = (GridView) findViewById(R.id.video_grid);
		bt_back = (Button) findViewById(R.id.bt_back);
		dbtoVideoListUtils = new DBtoVideoListUtils(videoList, this);
		Intent intent = getIntent();
		seasonInfo =  (SeasonInfo) intent.getSerializableExtra("seasonData");
		season_pic.setImageBitmap(BitmapFactory.decodeFile(seasonInfo.getImage_localUrl()));
		season_title.setText(String.valueOf(seasonInfo.getSeason_title()));
		season_count.setText(String.valueOf(seasonInfo.getSeason_count()));
		videoList = dbtoVideoListUtils.getVideoList(seasonInfo.getSeason_sort());
		video_grid.setAdapter(new SeasonGridAdapter(SeasonGridActivity.this, videoList));
		
		bt_back.setOnTouchListener(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				// TODO Auto-generated method stub
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					v.setBackgroundColor(0xff808080);
				} 
				else if (event.getAction() == MotionEvent.ACTION_UP) {
					v.setBackgroundColor(0xfff974c9);
					SeasonGridActivity.this.finish();
				}
				return false;
			}
		});
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.seasongrid);
	}
}
